<template>
  <div id="app">
   num的数量：{{appShowNum}}
   <button @click="addtion">增量</button>
    <router-view/>
  </div>
</template>

<script>
export default {
  name: 'App',
  data(){
    return{
      store:this.$store
    }
  },
  computed:{
    appShowNum(){
      return this.store.getters.getNum;
    }
  },
  methods:{
    addtion(){
      //一般写代码都不直接提交，除非明知道是同步操作，没有后台请求
      //this.$store.commit('addNum',{name:5})

      // this.store.commit({
      //   type:'addNum',
      //   num:5
      // })

      this.store.dispatch('addNumAsync',{num:5})
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
